At 16:41 +0200 on 15/10/1999, Moray McConnachie wrote:
> absolutely not, I tried that already.
> I get "attribute not found" error wherever the opening double-quotes
> are during the create of the function.
Not double quotes (The character "), but two single quotes one after the other.
Anyway, I would take a wholly different approach to this. I don't like
manipulating text and relying on the date format. I prefer working only
with dates and times. So I would use something like this:
testing=> CREATE FUNCTION dec_first( date ) RETURNS date as '
testing'> SELECT date( date_trunc( ''year'', $1 ) - ''1 month''::timespan )'
testing-> LANGUAGE 'sql';
CREATE
testing=> select dec_first('1980-08-14');
dec_first
----------
12-01-1979
(1 row)
testing=> select dec_first('1996-08-15');
dec_first
----------
12-01-1995
(1 row)
testing=> select dec_first('2004-02-14');
dec_first
----------
12-01-2003
(1 row)
Note how my doubled-quotes worked well?
Herouth
--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma